package com.youle;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by
 *
 * @author touni
 * @date 2019/4/28
 * @time 17:09
 */
@Configuration  //声明这是一个配置类
@EnableSwagger2 //启用swagger
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2).host("放的当前服务的域名地址").apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("需要生成文档的controller所在的包"))
                .paths(PathSelectors.any()).build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("文档的标题")
                .description("文档的描述")
                .version("文档的版本")
                .build();
    }
}
